namespace Crux.Core.Websockets;

/// <summary>
/// WebSocketClientProxy
/// </summary>
public class WebSocketClientProxy(ILifetimeManager lifetimeManager) : IWebSocketClientProxy
{
    /// <summary>
    ///
    /// </summary>
    private readonly ILifetimeManager _manager = lifetimeManager
                                                        ?? throw new ArgumentNullException(nameof(lifetimeManager));

    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public IClientProxy All()
        => new AllClientProxy(_manager);

    /// <summary>
    ///
    /// </summary>
    /// <param name="exceptConnectionIds"></param>
    /// <returns></returns>
    public IClientProxy AllExcept(params string[] exceptConnectionIds)
        => new AllExceptClientProxy(_manager, exceptConnectionIds);

    /// <summary>
    ///
    /// </summary>
    /// <param name="connectionId"></param>
    /// <returns></returns>
    public IClientProxy Client(string connectionId)
        => new ConnectionClientProxy(_manager, connectionId);

    /// <summary>
    ///
    /// </summary>
    /// <param name="connectionIds"></param>
    /// <returns></returns>
    public IClientProxy Clients(params string[] connectionIds)
        => new ConnectionsClientProxy(_manager, connectionIds);

    /// <summary>
    ///
    /// </summary>
    /// <param name="groupName"></param>
    /// <returns></returns>
    public IClientProxy Group(string groupName)
        => new GroupClientProxy(_manager, groupName);

    /// <summary>
    ///
    /// </summary>
    /// <param name="groupName"></param>
    /// <param name="exceptConnectionIds"></param>
    /// <returns></returns>
    public IClientProxy GroupExcept(string groupName, params string[] exceptConnectionIds)
        => new GroupExceptClientProxy(_manager, groupName, exceptConnectionIds);

    /// <summary>
    ///
    /// </summary>
    /// <param name="groupNames"></param>
    /// <returns></returns>
    public IClientProxy Groups(params string[] groupNames)
        => new GroupsClientProxy(_manager, groupNames);

    /// <summary>
    ///
    /// </summary>
    /// <param name="userId"></param>
    /// <returns></returns>
    public IClientProxy User(string userId)
        => new UserClientProxy(_manager, userId);

    /// <summary>
    ///
    /// </summary>
    /// <param name="userIds"></param>
    /// <returns></returns>
    public IClientProxy Users(params string[] userIds)
        => new UsersClientProxy(_manager, userIds);
}